//
//  ViewController.m
//  UI01-作业
//
//  Created by dllo on 16/6/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "CustomView.h"
@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self addCustomView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)addCustomView {
    CGFloat wight = self.view.bounds.size.width / 5;
    CGFloat height = self.view.bounds.size.height / 8;
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat r = 0;
    CGFloat g = 0;
    CGFloat b = 0;
    
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 5; j++) {
            @autoreleasepool {
                r = arc4random()%(10) / 10.0;
                g = arc4random()%(10) / 10.0;
                b = arc4random()%(10) / 10.0;
                [self.view addSubview:[CustomView customViewWithFrame:CGRectMake(x, y, wight, height) color:[UIColor colorWithRed:r green:g blue:b alpha:1]]];
                x += wight;
            }
        }
        x = 0;
        y += height;
    }
    
    
}

@end
